package com.t17;

import java.util.Iterator;
import java.util.TreeMap;

import static net.mindview.util.Print.print;

/**
 * Created by xuyiwei on 2018/8/15.
 */
public class SortedMapDemo {
    public static void main(String[] args) {
        TreeMap<Integer,String> sortedMap = new TreeMap<>(new CountingMapData(10));
        print(sortedMap);
        Integer low = sortedMap.firstKey();
        Integer high = sortedMap.lastKey();
        print(low);
        print(high);
        Iterator<Integer> iterator = sortedMap.keySet().iterator();
        for(int i=0;i<=6;i++){
            if(i==3) low = iterator.next();
            if(i==6) high = iterator.next();
            else iterator.next();
        }
        print(low);
        print(high);
        print(sortedMap.subMap(low,high));
        print(sortedMap.headMap(low));
        print(sortedMap.tailMap(high));
        /**
         * {0=A0, 1=B0, 2=C0, 3=D0, 4=E0, 5=F0, 6=G0, 7=H0, 8=I0, 9=J0}
         0
         9
         3
         7
         {3=D0, 4=E0, 5=F0, 6=G0}
         {0=A0, 1=B0, 2=C0}
         {7=H0, 8=I0, 9=J0}
         */
    }


}
